<template>
  {{ form }}
  <NvCrud v-model:form="form" :option :data />
</template>

<script setup lang="ts">
import type { NvCrudOption, RowData } from 'nv-crud'
import { NvCrud } from 'nv-crud'
import { ref } from 'vue'

const form = ref<RowData>({})
const data = Array.from({ length: 3 }, (_, i) => ({
  id: i + 1,
  name: `name${i + 1}`,
  sex: i % 2 === 0 ? '男' : '女',
  age: i + 1,
}))

const option: NvCrudOption = {
  actionbar: false,
  toolbar: false,
  rowActions: {
    width: 150,
    viewBtn: { content: false },
    editBtn: { renderIcon: false },
    delBtn: { text: false, size: 'tiny' },
  },
  fields: {
    name: { title: '姓名' },
    sex: { title: '性别' },
    age: { title: '年龄' },
  },
}
</script>
